--- 
title: Programming
---
<h1>Programming</h1>

<p>This page describes how to load compiled firmware onto an Ubertooth One or
Ubertooth Zero.  Other pages describe how to write <a
href="../../firmware/develop">firmware</a> or <a href="../../host/develop">host
code</a> for the platform.</p>

<p>There are three ways to program an Ubertooth board: the USB bootloader, the
ISP bootloader, and JTAG.</p>

<h2>USB bootloader</h2>

<p>This is the recommended method of loading code onto an Ubertooth Zero or
Ubertooth One provided that the USB bootloader is already installed (at the
time of manufacture, for example).  If you need to install the bootloader
itself, you will have to use either ISP or JTAG.</p>

<p>The bootloader executes every time the device starts up from reset or power
cycle.  Normally it just gets out of the way and passes control to the
application firmware very quickly.  Alternatively it can enter Device Firmware
Upgrade (DFU) mode which permits firmware upload and download over USB.  There
are two ways to tell the bootloader that you want it to enter DFU mode:</p>

<p>1. soft bootloader entry: By setting a flag in RAM, the application firmware
can instruct the bootloader to enter DFU mode following a reset (without loss
of power).  For example, with the bluetooth_rxtx firmware running you can
trigger a reset into DFU mode using 'ubertooth-util -f' (located in
host/bluetooth_rxtx/).  Soft entry only works on Ubertooth One, not Ubertooth
Zero.</p>

<p>2. hard bootloader entry (also known as pin entry): By connecting two pins
on the expansion header with a jumper during reset (either soft or hard boot),
you can force the bootloader into DFU mode.  When using pin entry, the
bootloader will enter DFU mode for only a few seconds and will then execute the
application if no DFU activity has started during that period.  This allows
developers to permanently or semi-permanently jumper the pins providing a DFU
opportunity on every reset.  This method works on Ubertooth One but not
Ubertooth Zero.</p>

<p>The bootloader indicates DFU mode by flashing the LEDs in a distinctive
pattern.  It also identifies itself as "usb_bootloader" on USB.</p>

<p>During DFU mode, firmware may be uploaded or downloaded using ubertooth-dfu.
See host/usb_dfu/README for usage instructions.</p>

<p>It is possible that soft bootloader entry may be broken by installing a
faulty application or an application that does not provide a method of
triggering soft entry.  In this case, pin entry must be used (e.g. by holding a
paper clip in the expansion header while plugging in the device) to "unbrick"
the unit.</p>

<p>For Ubertooth One, the pins to connect are pins 1 and 3 of the <a
href="../one/#pins">expansion header (P4)</a>.  For Ubertooth Zero, the pins to
connect are pins 1 and 13 of the expansion header (J1).</p>

<h2>ISP bootloader</h2>

<p>The LPC175x features an In-System Programming (ISP) bootloader that allows
code to be loaded over a serial interface.  In order to use ISP, you will need
<a href="http://sourceforge.net/projects/lpc21isp/">lpc21isp</a> and a 3.3V
serial programming device such as one of the following:</p>

<h3>Pogoprog</h3>

<p>The official Ubertooth ISP programmer is Pogoprog, an open source board that
can be assembled using a process similar to Ubertooth One assembly.</p>

<h3>an FTDI Basic Breakout - 3.3V</h3>

<p>You can use SparkFun's <a href="http://www.sparkfun.com/products/9873">FTDI
Basic Breakout - 3.3V</a> to program an Ubertooth.  Adafruit's <a
href="http://www.adafruit.com/index.php?main_page=product_info&products_id=284">FTDI
Friend</a> is a similar board that should work as well.  To allow lpc21isp to
automatically activate the LPC175x's ISP bootloader, you must modify the board
in one of two ways.</p>

<h4>method one: the easy way</h4>

<p>Just short the CTS pin to GND.  This will force the microcontroller into ISP
mode every time it resets while the programmer is connected.  In order to
perform a normal reset to run the newly loaded code, you will have to first
disconnect the programmer.</p>

<h4>method two: the better way</h4>

<p>Connect the CTS pin to the RTS pin (pin 3) on the FT232RL using fine gauge
wire such as wire wrap wire.  This is trickier to solder, but it has the
advantage that the pin will be fully controlled by lpc21isp.  This means that
you can leave the programmer connected to the Ubertooth board throughout
multiple program/test cycles.</p>

<h3>using ISP</h3>

<img src="../../images/pogoprog-placement.jpeg" alt="Pogoprog placement" />

<p>Warning: Code loaded via ISP will blow away the bootloader.  It is generally
recommended to use this method only for installing the bootloader itself.</p>

<p>Connect your serial programmer to the Ubertooth board and type &quot;make
program&quot; in the firmware source code directory.  If you have a precompiled
binary in .hex format, you can invoke lpc21isp directly with &quot;lpc21isp
-control firmware.hex /dev/ttyUSB0 230400 4000&quot; (replacing firmware.hex
with the firmware filename and /dev/ttyUSB0 with the device file of your serial
programmer.</p>

<h2>JTAG</h2>

<p>Warning: Code loaded via JTAG will blow away the bootloader.  It is
generally recommended to use this method only for installing the bootloader
itself.</p>

<p>Connect your ARM Cortex-M3 JTAG debugger (such as one supported by <a
href="http://openocd.berlios.de/web/">OpenOCD</a>) to the standard Cortex Debug
Connector on the Ubertooth One or the non-standard JTAG connector on the
Ubertooth Zero.  You know what to do.</p>
